<template>
  <view class="main-page myCenter">
    <view class="myCenter-bg-box">
      <image class="isbg myCenter-bg" src="/static/images/myCenter/bg.jpg" mode="aspectFill"></image>
    </view>
    <view class="content">
      <view class="content-box">
        <view class="img-box">
          <image v-if="userInfo.avatar" :src="userInfo.avatar" mode="scaleToFill" />
        </view>
        <view class="user-name">{{ userInfo.personName }}</view>
        <view class="user-next" v-if="userInfo.personPhone || userInfo.local">{{ userInfo.personPhone || ""
        }}{{ userInfo.personPhone && userInfo.local ? " | " : ""
          }}{{ userInfo.local || "" }}</view>
      </view>
      <view class="content-box box1">
        <view class="content-item" @click="linkTo('order')">
          <view class="content-icon">
            <image src="/static/images/myCenter/list.png" mode="scaleToFill" />
          </view>
          <view class="title">我的工单</view>
          <view class="count"><text>{{ all }}</text> 个</view>
        </view>
        <view class="content-item" @click="linkTo('order', 1)">
          <view class="content-icon">
            <image src="/static/images/myCenter/todo.png" mode="scaleToFill" />
          </view>
          <view class="title">我的待办</view>
          <view class="count"><text> {{ todo }} </text> 个</view>
        </view>
        <!-- <view class="content-i
          -->
      </view>
    </view>
  </view>
</template>

<script>
import { baseUrl } from "@/static/js/utils.js";
import { getList } from "@/api/hotline";
export default {
  name: "myCenter",
  components: {},
  props: {},
  data() {
    return {
      baseUrl,
      all: 0,
      todo: 0,
      userInfo: { personName: "", personPhone: "", local: "" },
    };
  },
  filters: {},
  computed: {},
  methods: {
    linkTo(url, tab = null) {
      uni.navigateTo({
        url: url + (tab ? "?tab=" + tab : ""),
      });
    },
    getUserInfo(userInfo) {
      this.userInfo = userInfo;
    },
    getCount() {
      getList({
        data: {
          transferStatus: true,
          receivingMan: "马山峰",
          pageNo: 1,
          pageSize: 100,
        },
        callback: ({ data }) => {
          console.log(data);
          this.all = (data?.list || [])?.length;
          this.todo = (data?.list || []).filter(
            (v) => !v.completionStatus
          )?.length;
        },
      });
    },
  },
  watch: {},

  // 页面周期函数--监听页面加载
  onLoad() {},
  // 页面周期函数--监听页面初次渲染完成
  onReady() {},
  // 页面周期函数--监听页面显示(not-nvue)
  onShow() {
    this.setUserReg(this.getUserInfo);
    this.getCount();
  },
  // 页面周期函数--监听页面隐藏
  onHide() {},
  // 页面周期函数--监听页面卸载
  onUnload() {},
  // 页面处理函数--监听用户下拉动作
  // onPullDownRefresh() { uni.stopPullDownRefresh(); },
  // 页面处理函数--监听用户上拉触底
  // onReachBottom() {},
  // 页面处理函数--监听页面滚动(not-nvue)
  // onPageScroll(event) {},
  // 页面处理函数--用户点击右上角分享
  // onShareAppMessage(options) {},
};
</script>

<style scoped lang="scss">
@import './style/index.scss';
</style>
